package chapter11;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * 外部类监听器，较少使用，除非某个事件被多个GUI界面共享，而且主要用来
 * 完成某种业务逻辑的实现才使用
 */
public class MailerListener implements ActionListener {

    private TextField email;

    public MailerListener() {}
    public MailerListener(TextField email) {
        this.email = email;
    }

    public void setEmail(TextField email) {
        this.email = email;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        System.out.println("程序向:" + email.getText() + "发送邮件");
    }
}
